package leetcode.editor.cn;

import java.util.Arrays;

public class P455AssignCookies {
    public static void main(String[] args) {
        Solution solution = new P455AssignCookies().new Solution();
        int[] g = {1, 2};
        int[] s = {1, 2, 3};
        System.out.println(solution.findContentChildren(g, s));
    }
    
    //leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public int findContentChildren(int[] g, int[] s) {
        Arrays.sort(g);
        Arrays.sort(s);
        int count = 0;
        for (int i = g.length - 1, j = s.length - 1; i >= 0 && j >= 0; ) {
            int c1 = g[i];
            int c2 = s[j];
            if (c2 >= c1) {
                count++;
                i--;
                j--;
            } else {
                i--;
            }
        }
        return count;
    }
}
//leetcode submit region end(Prohibit modification and deletion)

}